package server.service;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import server.domain.Archive;
import server.domain.Page;
import server.mapper.ArchiveMapper;

@Service
public class ArchiveService {
	@Autowired
	ArchiveMapper mapper;
	
	// 分页查询某一页数据
	public Page<Archive> findPage(Integer page, Integer size) {
		int total = mapper.getTotal();
		
		List<Archive> items = mapper.selectPage((page - 1) * size, size);
		
		Page<Archive> pageData = new Page<>();
		pageData.setTotal(total);
		pageData.setItems(items);
		
		return pageData;
	}
	public void delete(Integer id) {
		mapper.deleteByPrimaryKey(id);
	}
	public void udpate(Archive archive) {
		mapper.updateByPrimaryKey(archive);
	}
	public void insert(Archive archive) {
		mapper.insert(archive);
	}
	public boolean delBatch(Integer[] ids) {
		int rs=mapper.delBatch(ids);
		return rs==0 ? false : true;
	}
}
